# Create your views here.

from django.http import HttpResponse,request
from django.shortcuts import render,redirect
def index(request):
    return HttpResponse("index")

def index_page(request):
    # return HttpResponse("halo")
    # return render(request,"index.html")
    # return redirect("https://baidu.com")      # 重定向第三方网址
    return redirect("/welcome/")                # 转向本地

def welcome(request):
    return HttpResponse("python")

def reder_01(request):
    user_dict = {"name":"cat","age":8}
    return render(request,"index01.html",{"data":user_dict})

def login(request):
    if request.method == "POST":
        print(request.method)   # POST
        print(request.POST)     # <QueryDict: {'username ': ['jean'], 'password': ['123']}>
        print(type(request.POST))   # <class 'django.http.request.QueryDict'>
        # print(request.POST.get()) # 获取最后一个元素
        #         # print(request.POST.getlist())   # 获取所有
        return HttpResponse("user info")
    return render(request,"login.html")